package com.cytech.cloudclinic.adapter;

import android.widget.TextView;

import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.cytech.cloudclinic.R;
import com.cytech.cloudclinic.bean.Action;
import com.cytech.cloudclinic.bean.DrugTag;
import com.cytech.cloudclinic.bean.PrescriptionMenuModule;

import java.util.List;

/**
 * 处方药品分类标签
 */
public class PrescriptionDrugMenuAdapter extends BaseQuickAdapter<DrugTag, BaseViewHolder> {
    //默认全部不选中
    private int currentPos = 0;

    public PrescriptionDrugMenuAdapter(List<DrugTag> data) {
        super(R.layout.item_action_menu, data);

    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, DrugTag drugTag) {
        TextView tv = baseViewHolder.getView(R.id.item_action_menu_name);
        baseViewHolder.setText(R.id.item_action_menu_name,drugTag.name);


        if(baseViewHolder.getAdapterPosition()==currentPos){
            tv.setTextColor(ContextCompat.getColor(getContext(),R.color.colorPrimary));
            tv.setBackground(ContextCompat.getDrawable(getContext(),R.drawable.shape_round_real_bg_white_10));
        }else{
            tv.setTextColor(ContextCompat.getColor(getContext(),R.color.color_333333));
            tv.setBackground(null);
        }
    }

    public void setCurrentPos(int currentPos) {
        this.currentPos = currentPos;
        notifyDataSetChanged();
    }

}
